package ar.edu.uba.fi.jmit.graphvisualizer.client;

import java.io.Serializable;
import java.util.Map;

import ar.edu.uba.fi.jmit.graphvisualizer.client.widget.AverageMethodTimeWidget;
import ar.edu.uba.fi.jmit.graphvisualizer.client.widget.FieldValueWidget;
import ar.edu.uba.fi.jmit.graphvisualizer.client.widget.GraphVisualizerChart;
import ar.edu.uba.fi.jmit.graphvisualizer.client.widget.MethodInvocationCounterWidget;
import ar.edu.uba.fi.jmit.graphvisualizer.client.widget.MethodTimeWidget;
import ar.edu.uba.fi.jmit.graphvisualizer.client.widget.ObjectCountWidget;

public class ChartFactory {

	public static GraphVisualizerChart getChartForAppNameMonitorName(Map<String, Serializable> data) {
		GraphVisualizerChart chart = null;
		
		String monitorType = (String)data.get("monitor_type");
		if ("AVERAGE_METHOD_TIME".equals(monitorType)) {
			chart = new AverageMethodTimeWidget();
		} else
		if ("METHOD_INVOCATION_COUNTER".equals(monitorType)) {
			chart = new MethodInvocationCounterWidget();
		} else
		if ("METHOD_TIME".equals(monitorType)) {
			chart = new MethodTimeWidget();
		} else
		if ("OBJECT_COUNT".equals(monitorType)) {
			chart = new ObjectCountWidget();
		} else
		if ("FIELD_VALUE".equals(monitorType)) {
			chart = new FieldValueWidget();
		} else {
			//Desconocido
		}
		
		if (chart != null)
			chart.configure(data);
		
		return chart;
	}
	
}
